import { createContext, useContext } from 'react';

export interface DropdownMenuOptions {
  label: string;
  value: number | string;
  disabled?: boolean;
}

export type SoundPlayerType = {
  /** 设置音频 */
  setSoundUri: (uri: string) => void;
  /** 播放音频 */
  onPlay: () => void;
  /** 重新播放 */
  onReplay: () => void;
  /** 停止播放 */
  onStop: () => void;
  /** 暂停播放 */
  onPause: () => void;
  /// 设置播放速度
  onSpeedChange: (speed: number) => void;
  /** 播放状态 */
  playing: boolean;
  /** 音频uri */
  soundUri?: string;
};

export const SoundPlayerContext = createContext<SoundPlayerType>({} as SoundPlayerType);

export const useSoundPlayer = () => {
  const context = useContext(SoundPlayerContext);
  if (!context) {
    throw new Error('useSoundPlayer must be used within a DropdownMenuProvider');
  }
  return context;
};
